package org.yanghe.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.TimeUnit;

@RestController
public class ProviderController {

    @Value("${server.port}")
    private String port;

    @RequestMapping("/provider/hello/{name}")
    public String hello(@PathVariable("name") String name){
        //int a=10/0;
        return name+" Welcome  - ProviderController "+port;
    }

    /**
     * 测试超时
     * @param name
     * @return
     */
    @RequestMapping("/provider/timeout/{name}")
    public String testTimeOut(@PathVariable("name") String name){
        try {
            TimeUnit.SECONDS.sleep(3);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return name+" Welcome  - ProviderController "+port;
    }
}
